package com.yc.spring;

import com.yc.spring.bean.User;
import org.springframework.context.annotation.*;

// beans.xml
@Configuration
// 组件扫描 扫描加了 Component 注解的类
@ComponentScan("com.yc.spring")
public class BeanConfig {

    @Bean
    @Primary //  主bean
    @Scope("prototype")
    @Lazy
    public User user1(){
        User user = new User();
        user.setAge(18);
        user.setName("张三");
        return user;
    }

    @Bean({"user2","user3"}) // value
    public User user(){
        User user = new User();
        user.setAge(2);
        user.setName("李四");
        return user;
    }

}
